-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BE] feat: Specification을 Querydsl로 대체한다 (#604) #609
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리뷰 남겼습니다!
쿼리DSL 적용하니 확실히 깔끔하네요
backend/build.gradle
Outdated
configurations { | ||
compileOnly { | ||
extendsFrom annotationProcessor | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 설정 롬복 때문에 필요했던 것 같은데, QueryDSL 적용에도 필요한가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해제 했을 때 빌드 되는지 확인 필요할 것 같네요.
intelliJ, gradle 두 개 다요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
삭제했고 둘 다 빌드 되는 것 확인했습니다.
@@ -67,7 +67,8 @@ public enum ErrorCode { | |||
INVALID_ROLE_NAME("해당하는 Role이 없습니다."), | |||
FOR_TEST_ERROR("테스트용 에러입니다."), | |||
FAIL_SEND_FCM_MESSAGE("FCM Message 전송에 실패했습니다."), | |||
FCM_NOT_FOUND("유효하지 않은 MemberFCM 이 감지 되었습니다."); | |||
FCM_NOT_FOUND("유효하지 않은 MemberFCM 이 감지 되었습니다."), | |||
NOT_DEFINED_FESTIVAL_FESTIVAL("정의되지 않은 축제 필터입니다."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOT_DEFINED_FESTIVAL_FESTIVAL
아는 형님의 아는 형님의
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사용하지 않게 되어 삭제했습니다.
import java.time.LocalDate; | ||
import java.util.List; | ||
|
||
public interface FestivalRepositoryCustom { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repositories.single-repository-behavior
스프링 문서에는 접두사에 Custom을 사용하는데, 접미사로 Custom을 사용해주신 이유가 따로 있나요?
case PLANNED -> plannedFestivals(currentTime); | ||
case PROGRESS -> progressFestivals(currentTime); | ||
case END -> endFestivals(currentTime); | ||
default -> throw new InternalServerException(ErrorCode.NOT_DEFINED_FESTIVAL_FESTIVAL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switch에 Enum을 사용한다면, Default는 굳이 명시해주실 필요가 없습니다..!
왜냐하면 컴파일러가 어떠한 Enum이 있는지 알고 있기 때문이죠!!!
TMI로 해당 사항은 sealed
키워드를 구현한 클래스들도 포함이 됩니다. 아마 자바 17에선 안되고 그 이상에서는 되는걸로 기억하네요
private final JPAQueryFactory queryFactory; | ||
|
||
@Override | ||
public List<Festival> findFestivalBy(FestivalFilter festivalFilter, LocalDate currentTime) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
findByFilter
라는 이름은 어떠신가요?
또한, Clock을 의존하게 해서, LocalDate.now(clock)
을 내부에서 사용하게 한다면 인자로 들어오는 currentTime
은 필요 없을 것 같은데 이 부분은 테스트 용이성을 위해 열어두신건가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네네 맞아용
@SpringBootTest(webEnvironment = WebEnvironment.NONE) | ||
@Transactional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SpringBootTest(webEnvironment = WebEnvironment.NONE) | |
@Transactional | |
@RepositoryTest |
# Conflicts: # backend/src/test/java/com/festago/stage/repository/StageRepositoryTest.java
충돌 해결했습니당 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리뷰 반영 확인했습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
멋진 성장입니다 푸우.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Querydsl 멋있네요 👍
📌 관련 이슈
✨ PR 세부 내용
Specification 로직을 Querydsl로 변경했습니다
참고 자료 :
향로 Querydsl CustomRepository 를 중심으로
Querydsl 기본 사용법
SpringBoot 3.x 이상 gradle 설정